package com.woniu.humanresource.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Data
public class PageBean<T> {
	private List<T> beanList;
//	当前页
	private int pageIndex;
//	页大小，每页展示的数据
	private int pageSize;
//	总页数
	private int totalPage;
//	总条数
	private int totalRecord;
//	左边界页码
	private int beginPage;
//	右边界页码
	private int endPage;
//	路径
	private String url;

	//部门
	private List<Departments> departments;
	//职位
	private List<Position> positions;
	
	
	//除不尽，页码就加1
//	public int getTotalPage() {
//		return totalRecord%pageSize==0?totalRecord/pageSize:totalRecord/pageSize+1;
//	}
	
	
	
	public void setBeginEnd() {
		if(getTotalPage()<10) {
			beginPage=1;
			endPage=getTotalPage();
		}else{
			beginPage=pageIndex-5;
			endPage=pageIndex+4;
			if(beginPage<1) {
				beginPage=1;
				endPage=10;
			}
			if(endPage>getTotalPage()) {
				beginPage=getTotalPage()-9;
				endPage=getTotalPage();
			}
		}
		
	}
}
